package com.svconnect.plugin.builders;

import java.io.File;
import java.util.List;

import com.svconnect.plugin.model.wsdl.Service;

public abstract class BuilderBase {

	public static final String LIBRARY_PACKAGE = "com.svconnect";
	
	private boolean javaConventionEnabled = true;
	private String referenceDir = null;
	
	public boolean isJavaConventionEnabled() {
		return javaConventionEnabled;
	}

	public void setJavaConventionEnabled(boolean javaConventionEnabled) {
		this.javaConventionEnabled = javaConventionEnabled;
	}	
	
	public String getReferenceDir() {
		return referenceDir;
	}

	public void setReferenceDir(String referenceDir) {
		this.referenceDir = referenceDir;
	}	
	
	public void createPackageDir(List<Service> services, String packageName) {
		if (services!=null) {
			for(Service s : services) {
				String dirPaths = getPackageDir(s.getName(), packageName);
				new File(dirPaths).mkdirs();
			}
		}
	}
	
	public String getPackageDir(String serviceName, String packageName) {
		String dirPaths = packageName.replace(".", "/");
		dirPaths = String.format("%s/%s/src/%s", this.getReferenceDir(), serviceName, dirPaths);
		return dirPaths;
	}
}
